<!DOCTYPE html>
<html>
<head>
<title>积分规则</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<#include "../../../../include/resources.html">
<script type="text/javascript">
    var dataGrid;
    var winWidth = 500;
    var winHeight = 580;

	var modifyTitle = "编辑";
    var modifyUrl =  "/modules/user/score/rule/scoreRuleEditPage.html";
    var modifyWinParmeters = "'{0}','"+modifyTitle+"',920,650,'"+modifyUrl+"'";

    var disableUrl =  "/modules/user/score/rule/scoreRuleDisable.html";
    var enableUrl = "/modules/user/score/rule/scoreRuleEnable.html";
	var txt1 = "禁用";
	var txt2 = "启用";
	var val1 = 0;
	var val2 = 1;
    
    $(function() {
        dataGrid = $('#dataGrid').datagrid({
            url : '/modules/user/score/rule/scoreRuleList.html',
            fit : true,
            fitColumns : true,
            border : false,
            pagination : true,
            idField : 'id',
            pageSize : pageSize,
            pageNums : 1,
            pageList : pageList,
            sortName : 'id',
            sortOrder : 'asc',
            checkOnSelect : false,
            selectOnCheck : false,
            nowrap : false,
			singleSelect : true,
            columns:[[
                { field: 'id', title: '编号', width: 50, sortable:false },
                { field: 'name', title: '名称', width: 100, sortable:false},
                { field: 'value', title: '积分', width: 50, sortable:false },
                { field: 'status', title: '状态', width: 50, sortable:false,
                    formatter: function(value,row,index){
                        if(value==1){
                            return "启用";
                        }else if(value==0){
                            return "禁用";
                        }
                    }
                },
                { field: 'behavior', title: '积分行为', width: 50, sortable:false,
                    formatter: function(value,row,index){
                        if(value==1){
                            return "获取";
                        }else if(value==2){
                            return "消耗";
                        }else if(value==0){
                            return "不变";
                        }
                    }
                }, 
                { field: 'remark', title: '备注', width: 120, sortable:false },
                { field: 'addTime', title: '添加时间', width: 150, sortable:false,
              	  	formatter: function(value,row,index){
              	  		return getLocalTime(value,4);
              		}
                }, 
                { field : 'action',
                  	title : '操作',
                  	width : 75,
                  	fixed : true,
                  	formatter : function(value, row, index) {
						var status = row.status;
						var type = row.type;
						var str = '';
						str += '<dl>';
						str += '<dt><a href="javascript:void(0);" onclick="$.fn.dataGridOptions.editFun('+row.id+',modifyTitle,winWidth,winHeight,modifyUrl);" title="编辑名称">编辑</a><i class="iconfont">&#xe639;</i></dt>' ;
						str += '<dd>';
                        if(row.status==1){
                            str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.recordOptFun('+row.id+',disableUrl,txt1,val1);">禁用</a>';
                        } else if(row.status==0){
                            str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.recordOptFun('+row.id+',enableUrl,txt2,val2);">启用</a>';
                        }
						str += '</dd></dl>'
						return str;
                  	}
                } 
            ] ],
            toolbar : '#toolbar',
            onLoadSuccess : function() {
                $('#searchForm table').show();
                parent.$.messager.progress('close');
            }
        });
    });
</script>
</head>
<body style="padding:0 20px;" >
<div class="easyui-layout" data-options="fit : true,border : false">
    <div data-options="region:'north',border:false,collapsible:false" id="searchBox">
        <div class="sLeft">
            <form id="searchForm">
                <input type="text"  name="searchName" id="searchName" class="sInput" placeholder="输入名称进行搜索" autocomplete="off" onkeydown="if(event.keyCode == 13){ $.fn.dataGridOptions.searchFun('#searchForm');return false;}"/><a href="javascript:;" title="查询" class="sBtn" onclick="$.fn.dataGridOptions.searchFun('#searchForm');">查询</a>
                <a href="javascript:void(0);" class="reloadIcon" onclick="dataGrid.datagrid('reload');" title="刷新" ><i class="iconfont">&#xe603;</i></a>
            </form>
        </div>
    </div>
    <div data-options="region:'center'" style="margin-top:30px;padding-bottom:30px;">
        <table id="dataGrid"></table>
    </div>
</div>
<script src="${theme_dir}/js/search.js"></script>
</body>
</html>
